/**
  ******************************************************************************
  * @file    WF_GetRouterIP.c
  * @author  exatron
  * @version V1.0.0
  * @date    segunda, 22 de dezembro de 2014
  * @brief   Devolve pela serila o IP do gateway.
  ******************************************************************************
  * @attention
  *
  *
  ******************************************************************************
  */

/** @addtogroup WF
  * @{
  */

/* Includes ------------------------------------------------------------------*/
#include <common.h>

/* External functions --------------------------------------------------------*/

/** @defgroup WF_Functions
  * @{
  */

/**
  * @brief  Devolve pela serila o IP do gateway.
  * @param  Nenhum
  * @retval Devolve pela serial o IP ou Result_t
  */
void WF_GetRouterIP(void)
{
	char temp_buf[50];
	char gateway[50];

	bzero(temp_buf, sizeof(temp_buf));
	bzero(gateway, sizeof(gateway));

	if(aux_GetConnectionState() == Status_SoftAP)
	{
		strcpy(gateway, aux_FileRdLine(PATH_CONF, "gateway", "Erro GetNetwork\r\n"));
		aux_USART0_puts("%s=%d;%s\r\n", "WF_GRIP", Result_Ok, gateway);
	}
	else
	{
		if(aux_WF_GetIP() == Result_Ok)
			strcpy(temp_buf, aux_WF_GetCharRouterIP());

		if(strlen(temp_buf) > 0)
		{
			aux_USART0_puts("%s=%d;%s\r\n", "WF_GRIP", Result_Ok, temp_buf);
		}
		else
		{
			aux_USART0_puts("%s=%d\r\n", "WF_GRIP", Result_Error);
		}
	}

	aux_SetBusy(FALSE);
}

/**
  * @}
  */

/**
  * @}
  */

